import service from "@/request";
import { queryInt, resInt } from "../type";
import { addAdminInt, adminExport, adminQuery, resAdminInt } from "./type";

/**
 * 获取管理员接口
 */
export const getAdminApi = (data: adminQuery) => {
  return service<any, resInt<queryInt<resAdminInt[]>>>({
    url: "/admin",
    method: "get",
    params: data,
  });
};

/**
 * 添加管理员
 * @param data 
 * @returns 
 */
export const addAdminApi=(data: addAdminInt)=>service.post<any, resInt<string>>('/admin', data)

/**
 * 修改管理员信息
 * @param data 
 * @returns 
 */
export const editAdminApi=(data: addAdminInt)=>{
  return service<any, resInt<object>>({
    url: "/admin",
    method: "put",
    data,
  });
}
/**
 * 删除管理员
 * @param id
 * @returns
 */
export const delAdminApi = (id: number) => service.delete<any, resInt<string>>(`/admin/${id}`);

/**
 * 导出表格
 * @param data 
 * @returns 
 */
export const exportAdminApi=(data:adminExport)=>{
  return service({
    url: "/admin",
    method: "get",
    responseType: "blob",
    params: data,
  })
}